<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width,initial-scale=1" />
    <meta name="description" content="A fully featured admin theme which can be used to build CRM, CMS, etc." />
    <meta name="author" content="haijun.liu" />
    <title>修改系统用户</title>
    <link th:href="@{/images/favicon_1.ico}" rel="shortcut icon">
    <link  rel="stylesheet" type="text/css"  th:href="@{/plugins/sweetalert/dist/sweetalert.css}" />
    <link  rel="stylesheet" type="text/css"  th:href="@{/plugins/morris.js/morris.css}" />
    <link  rel="stylesheet" type="text/css"  th:href="@{/css/bootstrap.min.css}" />
    <link  rel="stylesheet" type="text/css"  th:href="@{/css/bootstrap-table.css}"  />
    <link  rel="stylesheet" type="text/css"  th:href="@{/css/bootstrapValidator.css}" />
    <link  rel="stylesheet" type="text/css"  th:href="@{/css/bootstrap-dialog.css}"  />
    <link  rel="stylesheet" type="text/css"  th:href="@{/css/core.css}" />
    <link  rel="stylesheet" type="text/css"  th:href="@{/css/app.css}" />
    <link  rel="stylesheet" type="text/css"  th:href="@{/css/icons.css}" />
    <link  rel="stylesheet" type="text/css"  th:href="@{/css/components.css}" />
    <link  rel="stylesheet" type="text/css"  th:href="@{/css/pages.css}" />
    <link  rel="stylesheet" type="text/css"  th:href="@{/css/menu.css}" />
    <link  rel="stylesheet" type="text/css"  th:href="@{/css/responsive.css}"  />
    <script th:src="@{/js/jquery.min.js}"></script>
    <script th:src="@{/js/bootstrap.min.js}"></script>
    <script th:src="@{/js/bootstrap-table.js}"></script>
    <script th:src="@{/js/bootstrap-table-zh-CN.js}"></script>
    <script th:src="@{/js/bootstrap-dialog.js}"></script>
    <script th:src="@{/js/bootstrapValidator.js}"></script>
    <script th:src="@{/js/app.js}"></script>
    <script th:src="@{/js/modernizr.min.js}"></script>
        <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
        <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
        <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
        <![endif]-->

        <script type="text/javascript">
            $(document).ready(function() {
                /**
                 * 返回
                 */
                $('#defaultForm').bootstrapValidator();
                $('#btn-goback').click(function () {
                    window.history.back();
                });

                /**
                 * 保存
                 */
                $('#btn-save').click(function () {
                    $('#form').bootstrapValidator('validate');
                    // 1. 验证表单
                    var rs=$('#form').data("bootstrapValidator").isValid();
                    if (rs){
                        var data =JSON.stringify( $("#form").serializeObject());
                        var options = {
                            url: '/system/sysUser/update',
                            type: 'post',
                            dataType: 'json',
                            data: $('#form').serialize(),
                            success: function (rs) {
                                if (rs.data){
                                    // 3. 判断后台保存成功后，弹出成功提示框并跳到查询列表
                                    showAlert('修改成功!',function () {
                                        window.location.href = '/system/sysUser/listSysUser';
                                    });
                                }
                            }
                        };
                        // 2. 发送ajax请求进行保存系统用户
                        $.ajax(options);
                    }
                });
            });
        </script>
    </head>
    <body class="fixed-left">
    <div class="panel panel-default"  style="">
        <div class="row">
            <!-- form: -->
                    <div class="panel-heading">修改</div>
                    <form id="form" class="form-horizontal"
                          data-bv-message="此值无效"
                          data-bv-feedbackicons-valid="glyphicon glyphicon-ok"
                          data-bv-feedbackicons-invalid="glyphicon glyphicon-remove"
                          data-bv-feedbackicons-validating="glyphicon glyphicon-refresh">
                        <input type="hidden" name="id" th:value="${sysUser.id}"/>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">用户名</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="username" th:value="${sysUser.username}"
                                       data-bv-message="用户名无效"
                                       required data-bv-notempty-message="用户名不能为空"
                                       pattern="[a-zA-Z0-9_\.]+" data-bv-regexp-message="The username can only consist of alphabetical, number, dot and underscore"
                                />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">真实姓名</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="realName" th:value="${sysUser.realName}" placeholder="真实姓名" required data-bv-notempty-message="真实姓名是必填的并且不能为空" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">邮箱</label>
                            <div class="col-sm-10">
                                <input class="form-control" name="email" type="email" th:value="${sysUser.email}" required data-bv-emailaddress-message="该输入是一个无效的邮件地址" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">密码</label>
                            <div class="col-sm-10">
                                <input type="password" class="form-control" name="password" th:value="${sysUser.password}"
                                       required data-bv-notempty-message="密码是必填的并且不能为空"
                                       data-bv-identical="true" data-bv-identical-field="confirmPassword" data-bv-identical-message="密码和确认密码不相同"
                                       data-bv-different="true" data-bv-different-field="username" data-bv-different-message="密码不能和用户名相同"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">确认密码</label>
                            <div class="col-sm-10">
                                <input type="password" class="form-control" name="confirmPassword"
                                       required data-bv-notempty-message="确认密码是必填的并且不能为空"
                                       data-bv-identical="true" data-bv-identical-field="password" data-bv-identical-message="密码和确认密码不相同"
                                       data-bv-different="true" data-bv-different-field="username" data-bv-different-message="密码不能和用户名相同"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">性别</label>
                            <div class="col-sm-10">
                                <div class="radio-inline">
                                    <label>
                                        <input type="radio" name="gender" value="1"  required data-bv-notempty-message="性别是必填的" /> 男
                                    </label>
                                </div>
                                <div class="radio-inline">
                                    <label>
                                        <input type="radio" name="gender" value="2" />女
                                    </label>
                                </div>
                                <div class="radio-inline">
                                    <label>
                                        <input type="radio" name="gender" value="0" /> 保密
                                    </label>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">手机码号</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="mobile" th:value="${sysUser.mobile}" placeholder="手机号"
                                       data-bv-message="手机号码无效"
                                       required data-bv-notempty-message="手机号码无效"
                                       pattern="[a-zA-Z0-9_\.]+" data-bv-regexp-message="The username can only consist of alphabetical, number, dot and underscore"
                                       data-bv-stringlength="true" data-bv-stringlength-min="11" data-bv-stringlength-max="11" data-bv-stringlength-message="电话号码必须是11位"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">电话号码</label>
                            <div class="col-sm-10">
                                <input type="text" class="form-control" name="tel" th:value="${sysUser.tel}"
                                       data-bv-message="电话号码无效"
                                       required data-bv-notempty-message="登录名不能为空"
                                       pattern="[a-zA-Z0-9_\.]+" data-bv-regexp-message="The username can only consist of alphabetical, number, dot and underscore"
                                       data-bv-stringlength="true" data-bv-stringlength-min="7" data-bv-stringlength-max="11" data-bv-stringlength-message="电话号码必须是7-11位"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">问题</label>
                            <div class="col-sm-10">
                                <select class="form-control" name="question">
                                    <option>---请选择---</option>
                                    <option>2</option>
                                    <option>3</option>
                                    <option>4</option>
                                    <option>5</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">答案</label>
                            <div class="col-sm-10">
                                <input placeholder="答案" class="form-control" type="text" name="answer" th:value="${sysUser.answer}" />
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-2 control-label"></div>
                            <input value="确定" id="btn-save" class="btn btn-primary" type="button">
                            &nbsp;&nbsp;
                            <input value="返回" id="btn-goback" class="btn btn-warning" type="button">
                        </div>
                    </form>
            <!-- :form -->
        </div>
    </div>
	</body>

</html>